package com.example.elmspringboot.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.elmspringboot.controller.utils.Result;
import com.example.elmspringboot.domain.Shop;
import com.example.elmspringboot.service.ShopService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/shop")
public class ShopController {
    @Resource
    private ShopService shopService;
    @GetMapping
    public Result getShops(@RequestParam Integer id){
        return new Result(true, shopService.list(new QueryWrapper<Shop>().eq("business_id", id)));
    }
    @PostMapping("/saveShop")
    public  Result saveShop(@RequestBody Shop shop){
        return new Result(true, shopService.save(shop));
    }
    @GetMapping("/all")
    public Result getAllShops(){
        return new Result(true, shopService.list());
    }

    @GetMapping("/getShop")
    public Result getById(@RequestParam Integer id){
        return new Result(true, shopService.getById(id));
    }
}
